/*
 * sys_env_conf.h
 *
 *  Created on: 2017年9月14日
 *      Author: Administrator
 */

#ifndef _SYS_ENV2_CONF_H_
#define _SYS_ENV2_CONF_H_

#ifdef __cplusplus
extern "C"
{
#endif  /* __cplusplus */
#include <stdint.h>
#include "board.h"

/*----------------------------------------------------------------------------*/
#include "sys_conf.h"
#define ENV2_SECTOR_SZ		( SYS_ENV2_SIZE )
#define ENV2_AREA			( SYS_ENV2_AREA )
#define ENV2_SECTOR_START	( SYS_ENV2_START )
#define ENV2_SECTOR_END		( SYS_ENV2_END )
#define ENV2_AREA_SZ		( ENV2_SECTOR_SZ / ENV2_AREA )

#define env2_flash_write(_addr,_buf,_len) _env2_flash_write(_addr,_buf,_len)/* 0-成功，-1-失败 */
#define env2_flash_read(_addr,_buf,_len) _env2_flash_read(_addr,_buf,_len)/* 0-成功，-1-失败 */
#define env2_flash_erase_sector(_sector) _env2_flash_erase_sector(_sector)/* 0-成功，-1-失败 */

/*----------------------------------------------------------------------------*/
extern int _env2_flash_write(uint32_t addr, void *buff, uint16_t len);/* 0-成功，-1-失败 */
extern int _env2_flash_read(uint32_t addr, void *buff, uint16_t len);/* 0-成功，-1-失败 */
#ifdef USING_QT_EMULATION
extern int _env2_flash_erase_sector(uint16_t sector);/* 0-成功，-1-失败 */
#elif defined(NRF51)
extern int _env2_flash_erase_sector(uint16_t sector);/* 0-成功，-1-失败 */
#else
//#include "drv_w25q128.h"
//#define _env2_flash_erase_sector w25q128_erase_sector
#include "drv2_spiflash.h"
#define _env2_flash_erase_sector spiflash_erase_sector
#endif
/*----------------------------------------------------------------------------*/

#ifdef __cplusplus
}
#endif  /* __cplusplus */
#endif /* _SYS_ENV2_CONF_H_ */
